<!-- /*
 * @Author: RDSunday 
 * @Date: 2020-03-23 14:42:08 
 * @Last Modified by:   RDSunday 
 * @Last Modified time: 2020-03-23 14:42:08 
 */ -->
<!-- 在屏幕底部弹出信息提示 -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #snackbar {
        visibility: hidden;
        min-width: 250px;
        margin-left: -125px;
        /* border: 1px solid #ccc; */
        background-color: #333;
        color: #fff;
        text-align: center;
        border-radius: 2px;
        padding: 16px;
        position: fixed;
        z-index: 1;
        left: 50%;
        bottom: 30px;
        font-size: 17px;
      }
      #snackbar.show {
        visibility: visible;
        -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; /* Safari and Chrome */
        animation: fadein 0.5s, fadeout 0.5s 2.5s;
      }
      /*Safari and Chrome*/
      @-webkit-keyframes fadein {
        from {
          bottom: 0;
          opacity: 0;
        }
        to {
          bottom: 30px;
          opacity: 1;
        }
      }

      @keyframes fadein {
        from {
          bottom: 0;
          opacity: 0;
        }
        to {
          bottom: 30px;
          opacity: 1;
        }
      }

      @-webkit-keyframes fadeout {
        from {
          bottom: 30px;
          opacity: 1;
        }
        to {
          bottom: 0;
          opacity: 0;
        }
      }

      @keyframes fadeout {
        from {
          bottom: 30px;
          opacity: 1;
        }
        to {
          bottom: 0;
          opacity: 0;
        }
      }
    </style>
  </head>
  <body>
    <h2>SnackBar</h2>
    <p>在屏幕底部弹出消息，作用与使用方法都与Toast类似</p>
    <p>点击按钮显示提示信息，3秒后消失</p>

    <button onclick="myFunction()">显示Snakbar</button>
    <div id="snackbar">一些文本.</div>
    <script>
      function myFunction() {
        var x = document.getElementById("snackbar");
        x.className = "show";
        setTimeout(function() {
          x.className = x.className.replace("show", "");
        }, 3000);
      }
    </script>
  </body>
</html>
